package pe.gob.inei.sirtod.domain.pk;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Embeddable;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;

@SuppressWarnings("serial")
@Embeddable
public class DatoMensualPK implements Serializable {

	@Column(name = "ANIO")
	private String periodo;

	@Column(name = "ID_DEPARTAMENTO")
	private int departamentoId;

	@Column(name = "INDICADOR_ID")
	private Integer indicadorId;

	public String getPeriodo() {
		return periodo;
	}

	public void setPeriodo(String periodo) {
		this.periodo = periodo;
	}

	public int getDepartamentoId() {
		return departamentoId;
	}

	public void setDepartamentoId(int departamentoId) {
		this.departamentoId = departamentoId;
	}

	public Integer getIndicadorId() {
		return indicadorId;
	}

	public void setIndicadorId(Integer indicadorId) {
		this.indicadorId = indicadorId;
	}
	
	@Override
	public int hashCode() {
		final HashCodeBuilder builder = new HashCodeBuilder();
		builder.append(getPeriodo());
		builder.append(getDepartamentoId());
		builder.append(getIndicadorId());
		return builder.toHashCode();
	}
	
	@Override
    public boolean equals(Object obj) {
		boolean isEquals = false;
		try {
			final DatoMensualPK other = (DatoMensualPK) obj;
			final EqualsBuilder builder = new EqualsBuilder();
			builder.append(getPeriodo(), other.getPeriodo());
			builder.append(getDepartamentoId(), other.getDepartamentoId());
			builder.append(getIndicadorId(), other.getIndicadorId());
			isEquals = builder.isEquals();
		} catch(Exception e) {
			isEquals = false;
		}
		return isEquals;
	}
}